class MyBlockingQueue {
    private int[] items = new int[10_000];

    private int head = 0;

    private int tail = 0;

    volatile private int size = 0;

    public void put(int value) throws InterruptedException {
        synchronized (this) {
            while (size == items.length) {
                this.wait();
            }
            items[tail] = value;
            tail++;
            if (tail == items.length) {
                tail = 0;
            }
            size++;
            this.notify();
        }
    }

    public Integer take() throws InterruptedException {
        int ret = 0;
        synchronized (this) {
            while (size == 0) {
                this.wait();
            }
            ret = items[head];
            head++;
            if (head == items.length) {
                head = 0;
            }
            size--;
            this.notify();
        }
        return ret;
    }
}

public class TestDemo {

}
